<?php
/*This class contains functions that prints various navbars:
language bar, multipage mode, printer & split bar

The common use is to set in a same cell the language bar, then multipage mode, then the printer bar
and to set the split bar in a cell below*/

class Navbar {
/*************************************************************************************/

cfunction PrtSplit() {
/*
this modules prints a basic split href menu
arguments:	
	_maxelmt: numbers of pages in the diary
	p	: current page to be seen
	lang	: current language (eng: English, frn: French

pattern: [<<Prev] | 1 --page+1 [2 --page+2 ...] | [Next>>] Page i of n
*/

global $lang,$_maxelmt,$p,$MAXHIT;

/*Default values*/
if($p=='') {
	$p=1;
}
else {
	/*replace any previous occurence of p with an empty string*/
	$this->qrystr=str_replace("&p=$p","",$this->qrystr);
}

/*sets language to an acceptable value*/
$this->SetLang();
/*replace any previous occurence of p with an empty string*/
$this->qrystr=str_replace("&lang=$lang","",$this->qrystr);

/*if MAXHIT=0 print a message error*/
if(!$MAXHIT) {
	print "MAXHIT=0 : no split available!\n";
}
else {

if($res && $_maxelmt) {
$end=$p*$MAXHIT;
if($_maxelmt < $p*$MAXHIT)
	$end=$_maxelmt;

print "\t\t&nbsp;Results ".(max(1,($p-1)*$MAXHIT+1)).'-'.$end.'&nbsp;&nbsp;<br>'."\n";
}

/*bypass if there's no more than one page*/

if ($_maxelmt> $MAXHIT) {
        /* pattern: Results i'-i'+MAXHIT [<<Prev] | 1 --page+1 [2 --page+2 ...] | [Next>>] Page i of n */

        /*<<Prev*/
        /*if p > 1, Prev is active, otherwise it's not*/
        print "\t\t<font face='Arial' size='1'";

        if (!($p-1)) {
        	print " color='#646464'>&lt;&lt;Prev&nbsp;|&nbsp;\n"; } /*light gray*/
        else	{
        	/*prev*/
        	$prevpage=$p-1;
        	$anurl = "dosearch.php3?$this->qrystr&p=$prevpage&lang=$lang";
        	print " color='#008000' ><a href=$anurl>&lt;&lt;Prev</a>&nbsp;|&nbsp;\n"; }
        print "\t\t</font>\n";
	
        /*print a page number every MAXHIT*/
        for($i=0;$i<$_maxelmt;$i+=$MAXHIT) {
        	/*page number i+1*/
        	$pi=($i/$MAXHIT)+1;
		
		/*don't activate current page's href*/
		if($pi==$p) {
			print "\t\t<font face ='Arial' size='1' color=#646464>$pi&nbsp;";
		}
		
		else {
        		$anurl = "dosearch.php3?$this->qrystr&p=$pi&lang=$lang";			
	        	print "\t\t<font face ='Arial' size='1' color=#008000 >\n";
	        	print "\t\t<a href=$anurl>".$pi.'&nbsp;</a>'."\n";
		}
		
        	print "\t\t</font>\n";
	}
	/*Next>>*/
        /*if p*MAXHIT doesn't meet or exceed MAXHIT, Next is active, otherwise it's not*/
        print "\t\t<font face ='Arial' size='1'";

        if (($_maxelmt-$p*$MAXHIT) <= 0) {
        	print " color='#646464'>| Next&gt;&gt;\n"; } /*light gray*/
        else	{
        	/*next*/
        	$nextpage=$p+1;
        	$anurl = "dosearch.php3?$this->qrystr&p=$nextpage&lang=$lang";
        	print ">|&nbsp;<a href=$anurl>Next&gt;&gt;</a>\n";}
        print "\t\t</font>";
	}

if($_maxelmt)
	print "\t\t<font face ='Arial' size='1' color='#008000' >&nbsp;Page ".$p.' of '.ceil($_maxelmt/$MAXHIT).'</font>'."\n";

}

return;
}

/*************************************************************************************/
cfunction SetLang() {
global $lang;

if($lang!='frn')
	$lang='eng';

return;
}
/*************************************************************************************/
cfunction SetQryStr() {
	
$this->qrystr=$GLOBALS[QUERY_STRING];
}
/*************************************************************************************/
/*end of class*/
};
?>
